<script setup lang="ts">
import {addUserLove, findUserById, itemRecommend} from "@/Network/userApi";
import {Ref, ref} from "vue";
import {findSongsByStyle, findSongByTitle, randomGenerateSongsByNum} from "@/Network/songApi";
import type {res} from "@/store/dataType";
import {itemRecSongs} from "@/store/songStore";

let userId = ref("11")
let userImg = ref()
findUserById(userId.value).then(res=>{
  // console.log(res.data)
  userImg.value = res.data.userImg
})

randomGenerateSongsByNum(3).then(res=>{
  // console.log(res.data[0].lrc)
})

let style={
  style:"民歌"
}
let styleSongs = ref()
findSongsByStyle(style).then(res=>{
  styleSongs.value = res.data
  // console.log(styleSongs.value)
})



addUserLove(11,1).then(res=>{
  // console.log(res.data)
})

// itemRecommend(11).then(res=>{
//   console.log(res.data)
// })
async function getItemRecSongs(userId){
  let res1:res<any> = await itemRecommend(userId)
  let songs = ref([])
  for(let i=0;i<res1.data.length;i++){
    let songTitle = {
      title:res1.data[i].song
    }
    let res2:res<any> = await findSongByTitle(songTitle)
    songs.value.push(res2.data)
  }
  itemRecSongs.value = songs.value
  console.log(itemRecSongs.value)
}

// getItemRecSongs(11)
</script>

<template>
  <img :src="userImg" alt="用户图片" class="w-12  rounded-full">
</template>

<style scoped>

</style>